const request = (url, data, successCallBack, errorCallBack) => {
    return wx.request({
        url: app.globalData.domain + url,
        header: {
            'Authorization': 'JWT ' + wx.getStorageSync('token')
        },
        data: data,
        method: 'POST',
        dataType: 'json',
        responseType: 'text',
        success: function (res) {
            if (res.statusCode !== 200) {
                wx.showModal({
                    content: res.data.errMsg,
                    showCancel: false
                });
            }
            else {
                successCallBack(res.data.data)
            }
        },
        fail: function (res) {
            wx.hideLoading();
            wx.showModal({
                content: "服务器连接超时。",
                showCancel: false
            });
            console.log(res)
        }
    })
};

const setToken = (token) => {
    wx.setStorageSync('token', token)
};

const getToken = (token) => {
    return wx.getStorageSync('token')
};